//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.lyq.bean.mySql;

import com.lyq.bean.Elective;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class GetElective_Sql {
    public GetElective_Sql() {
    }

    public Elective getElective_Sql(String cNo, String sNo) {
        (new MysqlLinking()).getLink();
        Connection conn = MysqlLinking.conn;
        Elective e = new Elective();
        if (conn != null) {
            try {
                String sql = "SELECT ec.C_No, ec.C_Name, ec.S_No, s.S_Name, ec.Grade " +
                             "FROM electcourse ec " +
                             "JOIN student s ON ec.S_No = s.S_No " +
                             "WHERE ec.C_No=? AND ec.S_No=?";
                PreparedStatement ps = conn.prepareStatement(sql);
                ps.setString(1, cNo);
                ps.setString(2, sNo);
                ResultSet rs = ps.executeQuery();

                while(rs.next()) {
                    e.setcName(rs.getString("C_Name"));
                    e.setsName(rs.getString("S_Name"));
                    e.setsNo(sNo);
                    e.setcNo(cNo);
                }
            } catch (Exception var8) {
                Exception s = var8;
                s.printStackTrace();
            }
        } else {
            System.out.println("数据库连接错误！");
        }

        return e;
    }
}